﻿@{
    Layout = "~/Views/Shared/_Layout.cshtml";
}

<form id="form1" method="post">
    <div class="mini-toolbar" style="padding: 2px; border-top: 0; border-left: 0; border-right: 0;">
        <table style="width: 100%;">
            <tr>
                <td style="white-space: nowrap;">
                    @Html.Partial("~/Views/Modular/SearchInfo.cshtml")
                </td>
                <td style="width: 100%;">
                    <span class="separator"></span>
                    <a class="mini-button" iconcls="icon-ok" onclick="onSelectOne" plain="true">选择</a>
                    <span class="separator"></span>
                    <a class="mini-button" iconcls="icon-close" onclick="CloseWindow" plain="true">关闭</a>
                </td>
            </tr>
        </table>
    </div>
    <div class="mini-splitter" style="width: 100%; height: 460px;">
        <div size="230" showcollapsebutton="true">
            <div class="mini-fit">
                <ul id="tree1" class="mini-tree" url=""
                    style="width: 100%; height: 380px;" expandonload="0" onnodeclick="getTreeData"
                    textfield="FName" idfield="FItemID" parentfield="FParentID" showtreeicon="true" resultastree="false">
                </ul>
            </div>
        </div>
        <div showcollapsebutton="true">
            <div id="datagrid1" class="mini-datagrid" style="width: 480px; height: 380px;" pagesize="10" idfield="FItemID"
                allowcellselect="true" allowcelledit="true" showcolumnsmenu="true"
                borderstyle="border:0;" url="/Coupon/GetCouponByClass"
                allowcellselect="true" allowcelledit="true" showcolumnsmenu="true" fitcolumns="false"
                onrowdblclick="onSelectOne" sortmode="client">
                <div property="columns">
                    <div type="checkcolumn"></div>
                    <div type="indexcolumn" width="35" headeralign="center">序号</div>
                    <div field="FItemID" width="0" visible="false" headeralign="center">内码</div>
                    <div field="FNumber" width="80" allowsort="true" headeralign="center">编码</div>
                    <div field="FName" width="200" allowsort="true" headeralign="center">名称</div>
                    <div field="FCorpName" name="FCorpName" width="150" allowsort="true" headeralign="center">所属商户</div>
                </div>
            </div>
        </div>
    </div>
    <input name="FTbName" class="mini-hidden" />
    <input name="FClassID" class="mini-hidden" />
</form>

<script>
    mini.parse();
    function SetData() {

    }

    function search() {

    }

    function onSelectOne() {
        var grid = mini.get("datagrid1");
        var rec = grid.getSelecteds();
        if (rec) {
            CloseWindow(rec);
        }
    }

    function getTreeData() {
        var grid = mini.get("datagrid1");
        var tree = mini.get("tree1");
        grid.load({ couponClassId: tree.getValue() });
    }

    function CloseWindow(action) {
        if (window.CloseOwnerWindow) window.CloseOwnerWindow(action);
        else window.close();
    }

    var grid = mini.get("datagrid1");

    //加载分类树
    function LoadListTree() {
        var tree = mini.get("tree1");
        if (tree == undefined)
            return;
        $.post('/Coupon/GetCouponItemTree', { mSystemAppID: parent.window.getSystemAppID() }, function (data) {
            tree.loadList(mini.decode(data).data);
            tree.select(0);
            getTreeData();
        });
    }

    LoadListTree();

</script>
